/**
 * 根据需求转化为自己需要的单位的文件大小，比如 KB/MB
 */
export const strategyMap = {
  /* Strategy 1: 将文件大小（bit）转化为 KB */
  bitToKB: val => {
    const num = Number(val)
    return isNaN(num) ? val : (num / 1024).toFixed(0) + 'KB'
  },

  /* Strategy 1: 将文件大小（bit）转化为 KB */
  bitToMB: val => {
    const num = Number(val)
    return isNaN(num) ? val : (num / 1024 / 1024).toFixed(0) + 'MB'
  }
}

export const strategyContext = (type, rowKey) => {
  return function(row, column, cellValue, index) {
    return strategyMap[type](row(rowKey))
  }
}

export default strategyContext
